/**
 * 模块：医院入驻平台-SysMenu
 */
package design.onekey.controller;

import design.onekey.annotation.LoginUser;
import design.onekey.base.BaseEntity;
import design.onekey.base.Response;
import design.onekey.model.dto.UserInfoDto;
import design.onekey.model.SysMenu;
import design.onekey.model.UserRole;
import design.onekey.model.dto.AuthTreeDto;
import design.onekey.model.dto.IndexMenuTreeDto;
import design.onekey.service.ISysMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
* @Description: SysMenucontroller类
* @author
* @date 2020-06-05 04:03:09
* @version V1.0
*/
@RestController
@RequestMapping("/api/sysMenu")
public class SysMenuController extends BaseController {

   /**
    * iSysMenuService服务注入
    */
   @Autowired
   private ISysMenuService iSysMenuService;

   /**
   * @Description: 分页查询表格
   * @param SysMenu
   * @param @return
   * @return BaseEntity
   * @throws
   */
   @RequestMapping(value = "/getTableList",method = RequestMethod.POST)
   public Response getTableList(@RequestBody SysMenu model)
   {

       BaseEntity result = new BaseEntity();
       result = iSysMenuService.tablePagingQuery(model);
       return Response.success(result);
   }

   /**
   * @Description: 获取详细信息
   * @param id
   * @param @return  BaseEntity
   * @return
   * @throws
   */
   @RequestMapping(value = "/getDetail",method = RequestMethod.GET)
   public Response getDetail(@RequestParam Long id) throws Exception
   {
       BaseEntity result = iSysMenuService.getDetail(id);
       return Response.success(result);
   }

   /**
   * @throws Exception
   * @Description: 新增
   * @param SysMenu
   * @return BaseEntity
   * @throws
   */
   @RequestMapping(value = "/insert",method = RequestMethod.POST)
   public Response insert(@RequestBody SysMenu model, @LoginUser UserInfoDto userInfoDto) throws Exception
   {
       BaseEntity result = iSysMenuService.insert(model,userInfoDto);
       return Response.success(result.getStatusMsg());
   }

   /**
   * @throws Exception
   * @Description: 更新
   * @param SysMenu
   * @return  BaseEntity
   * @throws
   */
   @RequestMapping(value = "/update",method = RequestMethod.POST)
   public Response update(@RequestBody SysMenu model) throws Exception
   {
       BaseEntity result = iSysMenuService.update(model);
       return Response.success(result.getStatusMsg());
   }

   /**
   * @Description: 单条删除
   * @param id
   * @return  BaseEntity
   * @throws
   */
   @RequestMapping(value = "/delete",method = RequestMethod.GET)
   public Response delete(@RequestParam Long id)
   {
       BaseEntity result = iSysMenuService.delete(id);
       return Response.success(result.getStatusMsg());
   }

   /**
   * @Description: 批量删除
   * @param SysMenu
   * @return BaseEntity
   * @throws
   */
   @RequestMapping(value = "/deletebatch",method = RequestMethod.POST)
   public Response deletebatch(@RequestBody List<Long> ids)
   {
       BaseEntity result = iSysMenuService.deleteBatch(ids);
       return Response.success(result.getStatusMsg());
   }

   /**
    * @Title: getAuthTree
    * @Description: 获取角色授权树
    * @param userRole
    * @param userInfoDto
    * @return
    * @author blcloak
    * @date 2020-06-11 09:57:11
    */
   @RequestMapping(value = "/getAuthTree",method = RequestMethod.POST)
   public Response getAuthTree(@RequestBody UserRole userRole, @LoginUser UserInfoDto userInfoDto)
   {
       AuthTreeDto result = iSysMenuService.getAuthTree(userRole, userInfoDto);
       return Response.success(result);
   }

   /**
    * @Title: getIndexMenu
    * @Description: 获取首页菜单树
    * @param userInfoDto
    * @return
    * @author blcloak
    * @date 2020-06-11 05:11:36
    */
   @RequestMapping(value = "/getIndexMenu",method = RequestMethod.POST)
   public Response getIndexMenu(@LoginUser UserInfoDto userInfoDto)
   {
       List<IndexMenuTreeDto> result = iSysMenuService.getIndexMenu(userInfoDto);
       return Response.success(result);
   }

   /**
    * @Title: getAllMenus
    * @Description: 获取所有的后台菜单
    * @return
    * @author blcloak
    * @date 2020-06-16 01:18:48
    */
   @RequestMapping(value = "/getAllMenus",method = RequestMethod.POST)
   public Response getAllMenus(@RequestBody SysMenu sysMenu){
       List<SysMenu> result = this.iSysMenuService.getAllMenus(sysMenu);
       return Response.success(result);
   }
}
